package org.kermeta.spem.activityautomation.eclipse.createdirectoryonsvnremoterepository;

import org.kermeta.spem.activityautomation.eclipse.createdirectoryonsvnremoterepository.actions.CreateDirectoryOnSVNRemoteRepositoryAction;
import org.kermeta.spem.activityautomation.eclipse.subclipseconfiguration.actions.SubclipseConfigurationActivityAutomation;
import org.kermeta.spem.activityautomationmanager.ActivityAutomation;
import org.kermeta.spem.executioncontext.ExecutionContext;
import org.kermeta.spem.processexecution.utils.model.ModelUtils;

public class CreateDirectoryAndConnectToSVNRepoActivityAutomation implements
		ActivityAutomation {

	public CreateDirectoryAndConnectToSVNRepoActivityAutomation() {
		// TODO Auto-generated constructor stub
	}

	@Override
	public void run(String contextModelPath) {
		ExecutionContext executionContext = ModelUtils.getExecutionContextRoot(contextModelPath);
		String urlRepoCreateDirectory = ModelUtils.getValueOfKey("url of the remote repository", executionContext);
		String directoryName = ModelUtils.getValueOfKey("name of the new directory to create on the repository", executionContext);
		
		String urlRepo = urlRepoCreateDirectory+"/"+directoryName;
		ModelUtils.setValueOfKeyIntoExecutionContextModel(executionContext, "url of the remote repository", urlRepo);
		
		//Create directory on the remote repository
		CreateDirectoryOnSVNRemoteRepositoryAction createDir = new CreateDirectoryOnSVNRemoteRepositoryAction();
		createDir.run(urlRepo, directoryName);
		
		//Add the newly created directory as remote repository
		SubclipseConfigurationActivityAutomation subConf = new SubclipseConfigurationActivityAutomation();
		subConf.run(contextModelPath);

	}

}
